class Solution 
{
public:
    int lengthOfLongestSubstring(string s) 
    {
        unordered_map<char,int> um;
        int maxlen = 0;
        
        for(int lhs = 0, rhs = 0;  rhs < s.size(); rhs++)
        {
            um[s[rhs]]++;
            while(um[s[rhs]] > 1)
            {
                um[s[lhs++]]--;
            }
            
            maxlen = max(maxlen,rhs-lhs+1);
            
        }
        
        return maxlen;
    }
};